#ifndef __AURA_THREAD_H__
#define __AURA_THREAD_H__

#define TLS_SLOT_SIZE 64

enum State {
    RUNNING    = 0x1,
    WAITING    = 0x2,
    SUSPENDING = 0x4,
    INTERRUPT  = 0x8,
    TIMEOUT    = 0x10,
    QUIT       = 0x80,
};

struct ThreadInfo : public DLinkNode {
    Aura_UInt32       m_uMagicnumberStart;
    Aura_ThreadId     m_iThreadId;
    CHAR*        m_pStack;
    Aura_UInt32       m_uState;
    Aura_Handle       m_hThradInfoLock;
    Aura_UInt32       m_uMagicnumberEnd;
    Aura_PVoid        m_pTlsSlots[TLS_SLOT_SIZE];

    ThreadInfo() :
        m_uMagicnumberStart(MAGIC_START_NUMBER),
        m_iThreadId(0),
        m_pStack(NULL),
        m_uState(RUNNING),
        m_hThradInfoLock(NULL),
        m_uMagicnumberEnd(MAGIC_END_NUMBER)
        { }
};

struct ThreadRef : public DLinkNode {
    ThreadInfo *        m_pThreadInfo;
    Aura_UInt32              m_uStore;
    ThreadRef(ThreadInfo *pThreadInfo) :
        m_pThreadInfo(pThreadInfo),
        m_uStore(0)
        { }
};

EXTERN ThreadInfo *GetCurrentThreadInfo();

#endif //__AURA_THREAD_H__
